#ifndef ECON_H
#define ECON_H

#include "defs.h"
#include "instruction.h"
#include "retour.h"
#include "emath.h"

enum OpBool { OP_LT = 1, OP_GT, OP_LET, OP_GET, OP_EQUAL, OP_NOTEQUAL, OP_AND, OP_OR, OP_NOT };
enum PrioBool { PRIO_COMB = 1, PRIO_NOT, PRIO_COMPARE, PRIO_PAREN_B };
enum { COND_INDEFINI, COND_OP, COND_EMATH, COND_BOOL, COND_CONSTCHAR, COND_VAR };

union PontType {
	Terme* te;
	token* to;
	Emath* e;
	bool cond;
};

struct TermeConditionnel {
	int type;
	PontType pt;
};

class Econ : public Instruction
{
public:
	virtual ~Econ();
	Econ();
	list<TermeConditionnel> convertir(list<TermeConditionnel> src);
	list<TermeConditionnel> separer(list<token> src);
	void construire(list<TermeConditionnel> src);
	Retour evaluer(map<string, Var_T> *loc, map<string, Var_T> *glob);
	Retour recupererVariable(map<string, Var_T> *contexte);

	Econ* droite;
	Econ* gauche;

	int type;
	PontType valeur;
	int operateur;

	bool estVariable;
	string nomVariable;
};

bool validerEcon(list<token> src);

#endif